package com.gk.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.study.entity.HomeWish;
import com.gk.study.mapper.HomeWishMapper;
import com.gk.study.service.HomeWishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
class HomeWishServiceImpl extends ServiceImpl<HomeWishMapper, HomeWish> implements HomeWishService {
    @Autowired
    HomeWishMapper mapper;

    @Override
    public List<Map> getThingWishList(String userId) {
        return mapper.getThingWishList(userId);
    }

    @Override
    public void createThingWish(HomeWish homeWish) {
        mapper.insert(homeWish);;
    }

    @Override
    public void deleteThingWish(String id) {
        mapper.deleteById(id);
    }

    @Override
    public  HomeWish getThingWish(String userId, String homeId) {
        QueryWrapper<HomeWish> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("thing_id", homeId)
                .eq("user_id", userId);
        return mapper.selectOne(queryWrapper);
    }
}
